#include <cctype>
#include <cstdio>
using namespace std;

int cky_read(){
	int res = 0;
	char ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)){
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	}
	return res;
}

int n,L,R,tmp;

int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	n = cky_read();
	L = cky_read();
	R = cky_read();
	if (L == R){
		printf("%d",L % n);
	}
	else if (R - L + 1 >= n){
		printf("%d",n - 1);
	}
	else if (L - (L % n) + n - 1 <= R){
		printf("%d",n - 1);
	}
	else{
		printf("%d",R % n);
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
